<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>

import Login from "./components/Login";
export default {
  name: 'App',

  components: {Login},

  // 页面挂载的时候添加一个浏览器刷新的监听事件 刷新时调用saveState
  mounted() {
    window.addEventListener('unload', this.saveState);
  },
  methods: {
    saveState() {
      //把$store中的数据保存到浏览器的sessionStorage里
      sessionStorage.setItem('state', JSON.stringify(this.$store.state));
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
